package jp.co.showbiz.admin.member.action;

import java.util.HashMap;

import jp.co.showbiz.admin.member.imp.MemberDTO;
import jp.co.showbiz.admin.member.imp.MemberImpl;
import jp.co.showbiz.common.base.BaseActionSupport;

import com.opensymphony.xwork2.ModelDriven;

@SuppressWarnings("serial")
public class MemberAction extends BaseActionSupport implements ModelDriven<MemberDTO> {
	
	MemberImpl impl;
	MemberDTO dto;

	//画面引渡しパラメタ
	HashMap<String, Integer> pageMap;
    int curPage;
    
    /**
     * {@inheritDoc}
     * @throws Exception 
     */
    @Override
    public void prepare() throws Exception {
    	if(impl == null) {
    		impl = new MemberImpl();
    	}
    	if(dto == null) {
    		dto = new MemberDTO();
    	}
    	if(pageMap == null) {
    		pageMap = new HashMap<String, Integer>();
    	}
    }
    
	public String execute() throws Exception{
		logger.debug("default execute");
		return SUCCESS;
	}
	
	@Override
    public void validate() {
    	super.validate();
    }
	
	//=======================================================
	// Action処理
	//===========================<Start>=====================
	public String memberList() throws Exception{
		logger.debug("memerList");
		
		impl.user_list(dto, curPage);
		pageMap = dto.getPageMap();
		
		return SUCCESS;
	}
	
	public String memberSearch() throws Exception{
		logger.debug("memberSearch");
        memberList();
		return SUCCESS;
	}
	
	public String memberInfo() throws Exception{
		logger.debug("memberInfo");
		
		impl.user_query(dto);
		
		return SUCCESS;
	}
	
	public String memberFavorite() throws Exception{
		logger.debug("memberFavorite");
		
		impl.favorite_list(dto, curPage);
		pageMap = dto.getPageMap();
		
		return SUCCESS;
	}
	
	public String memberPoint() throws Exception{
		logger.debug("memberPoint");
		
		impl.point_query(dto);
		
		return SUCCESS;
	}
	
	public String memberDownload() throws Exception{
		logger.debug("memberDownload");
		
		impl.point_dl_list(dto, curPage);
		pageMap = dto.getPageMap();
		
		return SUCCESS;
	}
	
	public String memberPayment() throws Exception{
		logger.debug("memberPayment");
		
		impl.point_info_list(dto, curPage);
		pageMap = dto.getPageMap();
		
		return SUCCESS;
	}
    //=======================<End>===================================
	
	//===============================================================
	//画面引渡しパラメタGet,Set
	//=======================<Start>=================================
	public HashMap<String, Integer> getPageMap() {
		return pageMap;
	}
	public void setPageMap(HashMap<String, Integer> pageMap) {
		this.pageMap = pageMap;
	}
	public int getCurPage() {
		return curPage;
	}
	public void setCurPage(int curPage) {
		this.curPage = curPage;
	}
	
	public MemberDTO getMemberDTO() {
		return dto;
	}
	public void setMemberDTO(MemberDTO memberDTO) {
		this.dto = memberDTO;
	}
	//==========================<End>==================================

	public MemberDTO getModel() {
		// TODO Auto-generated method stub
		return dto;
	}
}
